<?php
/**
 * 会员模块
 */
namespace app\admin_module\controllers;

use app\common\Helpers;
use app\models\ShopMember;
use app\models\User;
use Codeception\PHPUnit\Constraint\Page;
use Yii;
use yii\data\Pagination;


class MemberController extends CommonController
{
    public $layout='layout';

    public function actionIndex()
    {
        $member = new ShopMember(['scenario'=>SCENARIO_STORE]);


        $res=$member->load([
            'id'=>5,
            'name'=>'test',
            'aaa' => 'bbb',
        ],'');
        print_r($member->name);die;
        return $this->render('index');
    }

    /**
     * 会员列表
     */
    public function actionList()
    {
        $query=ShopMember::find();

        $data=Helpers::pagination($query,8);

        return $this->render('list',$data);
    }

    /**
     * 删除会员
     */
    public function actionDel()
    {

    }

    /**
     * 添加会员
     * @throws
     */
    public function actionAdd()
    {
        $model=new ShopMember();
        if(Yii::$app->request->isPost){
            //post过来的数据，视为登录操作
            $post=Yii::$app->request->post();
            $model->storeManager($post);

            //跳列表页
            $this->redirect(['member/list']);
            Yii::$app->end();

        }else{
            return $this->render('add',['model'=>$model]);
        }
    }

}
